//
//  TSCellMoveCollectionViewCell.m
//  AllScrollViewDemo
//
//  Created by ciyouzen on 2016/06/07.
//  Copyright © 2016年 dvlproad. All rights reserved.
//

#import "TSCellMoveCollectionViewCell.h"
#import <Masonry/Masonry.h>
#import <CQDemoKit/CQTSButtonFactory.h>

@interface TSCellMoveCollectionViewCell () {
    
}
@property (nonatomic, strong) UIButton *textButton; /**< 文本按钮 */

@end

@implementation TSCellMoveCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setupViews];
//        self.selected = NO;
    }
    return self;
}

#pragma mark - SetupViews & Lazy
- (void)setupViews {
    [self.contentView addSubview:self.textButton];
    [self.textButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(2);
        make.centerX.equalTo(self.contentView);
        make.top.equalTo(self.contentView).offset(2);
        make.centerY.equalTo(self.contentView);
    }];
}


- (UIButton *)textButton {
    if (_textButton == nil) {
        UIButton *textButton = [CQTSButtonFactory submitButtonWithSubmitTitle:nil editTitle:nil showEditTitle:NO clickSubmitTitleHandle:nil clickEditTitleHandle:nil];
        [textButton.titleLabel setFont:[UIFont systemFontOfSize:14.0]];
        textButton.layer.cornerRadius = 10;
        textButton.userInteractionEnabled = NO; // 使得按钮位置的cell能够接收点击事件
        _textButton = textButton;
    }
    
    return _textButton;
}

#pragma mark - Setter
- (void)setSelected:(BOOL)selected {
    [super setSelected:selected];
    
    self.textButton.selected = selected;
}

- (void)setText:(NSString *)text {
    _text = text;
    [self.textButton setTitle:text forState:UIControlStateNormal];
    [self.textButton setTitle:text forState:UIControlStateSelected];
}

@end
